package com.dreamcar.auction.entity;

import java.util.HashSet;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.OneToOne;

import static javax.persistence.GenerationType.IDENTITY;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 * Bid entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "bid", catalog = "assignment")
public class Bid implements java.io.Serializable {

	// Fields

	private Integer idBid;
	private Supplier supplier;
	private Request request;
	private String amount;
	private Boolean winner;
	private PurchaseOrder purchaseOrder;

	// Constructors

	/** default constructor */
	public Bid() {
	}

	/** minimal constructor */
	public Bid(Supplier supplier) {
		this.supplier = supplier;
	}

	// Property accessors
	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "id_bid", unique = true, nullable = false)
	public Integer getIdBid() {
		return this.idBid;
	}

	public void setIdBid(Integer idBid) {
		this.idBid = idBid;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "id_supplier", nullable = false)
	public Supplier getSupplier() {
		return this.supplier;
	}

	public void setSupplier(Supplier supplier) {
		this.supplier = supplier;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "id_request")
	public Request getRequest() {
		return this.request;
	}

	public void setRequest(Request request) {
		this.request = request;
	}

	@Column(name = "amount", length = 45)
	public String getAmount() {
		return this.amount;
	}

	public void setAmount(String amount) {
		this.amount = amount;
	}

	@Column(name = "winner")
	public Boolean getWinner() {
		return this.winner;
	}

	public void setWinner(Boolean winner) {
		this.winner = winner;
	}

	@OneToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "bid")
	public PurchaseOrder getPurchaseOrder() {
		return this.purchaseOrder;
	}

	public void setPurchaseOrder(PurchaseOrder purchaseOrder) {
		this.purchaseOrder = purchaseOrder;
	}

}